<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>添加系统设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" type="text/css" href="../mobile/js/layer/css/layui.css" />
  <link rel="stylesheet" type="text/css" href="css/style.css" />
  <script src="../mobile/js/layer/layui.js"></script>
  <script src="./js/jquery-1.9.1.js"></script>
  <script src="./js/common.js"></script>
</head>
<body>
    <br>
    <div class="x-body layui-anim layui-anim-up">
        <form method="post" class="layui-form">
          <div class="layui-form-item">
              <label for="L_name" class="layui-form-label">
                  <span class="x-red">*</span>名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="L_name" name="name" required lay-verify="name"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>3~16个英文数字下划线组成的字符
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_value" class="layui-form-label">
                  <span class="x-red">*</span>内容
              </label>
              <div class="layui-input-block">
                      <textarea placeholder="请输入内容" id="L_value" name="value" class="layui-textarea"  lay-verify="value"
                  autocomplete="off" style="width:90%" required></textarea>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_type" class="layui-form-label">
                  <span class="x-red">*</span>类型
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="L_type" name="type" required="" lay-verify="type"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>英文组成的字符
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_desc" class="layui-form-label">
                  <span class="x-red">*</span>描述
              </label>
               <div class="layui-input-block">
                      <textarea placeholder="请输入内容" id="L_desc" name="desc" class="layui-textarea"  lay-verify="desc"
                  autocomplete="off" style="width:90%;min-height:20px;" required></textarea>
              </div>
          </div>
          <div class="layui-form-item">
             <label for="L_repass" class="layui-form-label">
              </label>
              <button  type="submit" class="layui-btn btns" lay-filter="add" lay-submit=""  style="margin-left: 160px;">
                  添加
              </button>
          </div>
      </form>
    </div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
      var form = layui.form
      ,layer = layui.layer;
    
      //自定义验证规则
      form.verify({
        name: [/^[a-zA-Z0-9_]{3,16}$/ , '名称必需3~16个英文数字下划线组成的字符']
        ,value: [/(.+){1,512}$/, '内容必须1~512个字符']
        ,type: [/^[a-zA-Z]{3,16}$/, '3~16英文组成的字符']
        ,desc: [/^(.+){1,64}$/, '1~50个字符组成的字符串']
      });
      //监听提交
      form.on('submit(add)', function(data){
        var urls = url + "/admin/config/add";
        $.post(urls,data.field,function(msg){
            var msg = JSON.parse(msg);
            if(msg.code == 1){
               layer.alert(msg.infomsg, {icon: 6},function () {
                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
                parent.layer.close(index);
              });
            }else{
                layer.alert(msg.infomsg, {icon: 5},function () {
               // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
                parent.layer.close(index);
              });
            }
        })
          return false;
      });
      
      
    });
</script>
</body>
</html>